import type { PlusColumn } from 'plus-pro-components'

import { agreementStateOptions, agreementTypeOptions } from '../constant'

export function useForm() {
    const schema: PlusColumn[] = [
        {
            colProps: {
                span: 6,
            },
            label: '状态',
            options: agreementStateOptions,
            prop: 'agreementState',
            valueType: 'select',
        },
        {
            colProps: {
                span: 6,
            },
            label: '协议类型',
            options: agreementTypeOptions,
            prop: 'agreementType',
            valueType: 'select',
        },
        {
            colProps: {
                span: 6,
            },
            label: '协议编号',
            prop: 'agreementCode',
            valueType: 'copy',
        },
        {
            colProps: {
                span: 6,
            },
            label: '协议名称',
            prop: 'agreementName',
            valueType: 'copy',
        },
        {
            colProps: {
                span: 6,
            },
            label: '乙方',
            prop: 'partyB',
            valueType: 'copy',
        },
    ] as const

    const state = {
        agreementCode: '',
        agreementName: '',
        agreementState: '',
        agreementType: '',
        partyB: '',
    }
    const form = ref({
        ...state,
    })

    function reset() {
        form.value = {
            ...state,
        }
    }

    return { form, reset, schema, state }
}
